<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>频谱回放</title>
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/jquery-easyui-1.3.3/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/jquery-easyui-1.3.3/themes/icon.css">
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/jquery-easyui-1.3.3/demo/demo.css">
	<script type="text/javascript" src="${pageContext.request.contextPath}/static/jquery-easyui-1.3.3/jquery.min.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/static/jquery-easyui-1.3.3/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/static/jquery-easyui-1.3.3/locale/easyui-lang-zh_CN.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/static/Highcharts-5.0.14/code/highcharts.js"></script>
	<script src="${pageContext.request.contextPath}/static/Highcharts-5.0.14/code/modules/exporting.js"></script>
	<script src="https://img.hcharts.cn/highcharts-plugins/highcharts-zh_CN.js"></script>
	<!-- 中文包要放在exporting.js下面，否则无效 -->
	<style type="text/css">
	.slider.slider-h {
    	display: inline-block;
	}
	.slider-inner {
		padding-top: 12px ;
	}
	.slider-handle {
		margin-top: 6px;
	}
	</style>
	
</head>
<body>
    <div style="margin-top:6px;margin-left:10px;">
 	 	&nbsp;前置机名：&nbsp;
 		<input class="easyui-combobox" id="frontId" style="width:130px" name="frontId" data-options="panelMaxHeight:'200',valueField:'id',textField:'name',url:'${pageContext.request.contextPath}/interferencequery/frontIdBox.do'"/>
 	    &nbsp;时间：&nbsp;<input type="text" id="i1" size="20" class="easyui-datetimebox" style="width:140px"/>&nbsp;至&nbsp;
		<input type="text" id="i2" size="20" class="easyui-datetimebox"  style="width:140px" />
		&nbsp;&nbsp;<input name="fresh" type="button" id="fresh" value="刷新时间" onclick="getvalues();"/>
		&nbsp;&nbsp;<input name="start" type="button" id="start" value="开始回放" onclick="play();"/>
		&nbsp;&nbsp;<input name="operation" type="button" id="operation" value="暂停" onclick="dealwith(this.value);"/>
		
 		<textarea id="bs_info" style="float:right;width:250px;height:86px;border:solid 1px;border-color:rgb(180,180,180);outline:none;resize:none;margin-right:100px;padding-top:15px;padding-left:20px" readonly></textarea>
	</div>
	
	<br>
    
 	<div style="margin-top:5px;margin-left:10px;">
 		&nbsp;当前时刻：<input type="text" id="currenttime" name="currenttime" class="easyui-validatebox" values="" style="text-align:center;width: 140px" />
        &nbsp;&nbsp;回放速度：<input class="easyui-combobox" id="speed" 
					    data-options="panelHeight:'auto',valueField:'lable',textField:'value',
					    data:[{lable:'0', value:'0.8'}, {lable:'1', value:'1'}, {lable:'2', value:'5'},  {lable:'3', value:'10'}]" 
					    value="1" style="text-align:center;width: 50px" editable="false"/>&nbsp;&nbsp;秒
        &nbsp;&nbsp;<input name="refresh" type="button" id="refresh" value="更新回放速度" onclick="play2();"/>
        
        &nbsp;&nbsp;&nbsp;&nbsp;<input name="adjust" type="button" id="adjust" value="频谱扩展" onclick="dealwithadjust(this.value);"/>
        <span>     
        	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        	<input id="inp" class="easyui-slider" value="0" data-options="showTip:false"  style="width:200px;">
        </span>
 	</div>
 	<br><br><br><br>
    <!-- 图表 -->
	<div id="container" style="float:left;width:calc(50%);height:500px"></div>
	<div id="container2" style="float:right;width:calc(50%);height:500px"></div>
	<!-- 5个最大极点的显示 -->
	<div >
		<textarea id="pole_up" style="float:left;width:calc(49%);height:80px;resize:none;margin-bottom:20px" readonly></textarea>
		<textarea id="pole_down" style="float:right;width:calc(49%);height:80px;resize:none;margin-bottom:20px" readonly></textarea>
		
	</div>
	<div style="margin-bottom:5px">
		<a href="javascript:exporFscanData()" class="easyui-linkbutton" iconCls="icon-save" plain="true">导出当前页fscan数据</a>
		<a href="javascript:exporHistoryFscanData()" class="easyui-linkbutton" iconCls="icon-save" plain="true">导出历史fscan数据</a>
		&nbsp;&nbsp;&nbsp;&nbsp;导出历史时间：&nbsp;<input type="text" id="i3" style="width:calc(8%)" class="easyui-datetimebox"/>
 		&nbsp;至&nbsp;<input type="text" id="i4" style="width:calc(8%)" class="easyui-datetimebox"/>
	</div>
	<!-- fscan表结果 -->
	<div  id="tab" style="width:calc(100%);height:250px">
    	<table id="fscandata" title="fscan表数据"></table>
	</div> 
	

	<script>
	
	
	function exporFscanData() {
		var rows  = $('#fscandata').datagrid("getRows");
		if (rows.length < 1) {
			$.messager.alert("系统提示", "请查询需要导出的数据");
			return;
		}
    	var params = {data:JSON.stringify(rows)};
    	postExcelFile(params, "${pageContext.request.contextPath}/interferencequery/exportcurrentpage.do");
	}
	function exporHistoryFscanData() {
		var startTime=$("#i3").datebox("getValue");
		var endTime=$("#i4").datebox("getValue");
		startDate = new Date(startTime.replace(new RegExp("-","gm"),"/"));
		endDate = new Date(endTime.replace(new RegExp("-","gm"),"/"));
		var startTimeLong = startDate.getTime();
		var endTimeLong = endDate.getTime();
		window.open('${pageContext.request.contextPath}/interferencequery/exporthistoryfscan.do?startTime='+startTimeLong+'&endTime='+endTimeLong);
	}
	function postExcelFile(params, url) { //params是post请求需要的参数，url是请求url地址
	    var form = document.createElement("form");
	    form.style.display = 'none';
	    form.action = url;
	    form.method = "post";
	    document.body.appendChild(form);

	    for(var key in params){
	      var input = document.createElement("input");
	      input.type = "hidden";
	      input.name = key;
	      input.value = params[key];
	      form.appendChild(input);
	    }
	    form.submit();
	    form.remove();
	}
	var index=0;
	var flag=true;
	var getdata=false;
    var time;
    var status=false;
    var isreplay=false;
    var status2=false;
    var isreplay2=false;
    var FrontId="";
    var tmpFrontId;
    var TimeBegin;
    var TimeEnd;
    var timer;
    var timer2;
    var FSpectrum=new Array();   //上行
    var FSpectrum1=new Array();  //下行
    var currenttime=new Array();
    var poleup=new Array();
    var poledown=new Array();
    var TimeBeginlong;
    var TimeEndlong;
    var MiddleTime;
    var Current_time;
    var isAdjust="0"; //没有调整频谱
    var FScan=new Array(); //FScan数据
    var BusyModelUp=new Array();
    var BusyModelDown=new Array();
    var LeisureModelUp=new Array();
    var LeisureModelDown=new Array();
    var BusyModelUpAd=new Array();
    var BusyModelDownAd=new Array();
    var LeisureModelUpAd=new Array();
    var LeisureModelDownAd=new Array();
    
    var reference=-100;  //参考底噪 后续可以根据数据库字段，在初始化时获取
    var range=3;    //目前设置为3可以根据需求在初始化时读取数据库的相应字段
    
    var bottomNoiseThreshold = new Array();
    
    /* var p1;
    var p2; */
    var status=false;
	
	
	$(function() {
		
		$('#inp').slider({
	        onSlideEnd:function (value) {
	        	console.log('value: ' + value);
	            console.log('FrontId: ' + FrontId);
	            
	            
	            
	            
	        	if(FrontId==""||TimeBegin=="" || TimeBegin==null||TimeEnd==""||TimeEnd==null||FrontId==null){
	        		$.messager.alert("系统提示","请先选择参数并开始回放！");
	        		$('#inp').slider("setValue", 0);
	        		return;
	        	}
	            
	            
	            
	            var timeBegin=$("#i1").datebox("getValue");
	        	var timeEnd=$("#i2").datebox("getValue");
	        	var startTimeLong = new Date(timeBegin.replace(new RegExp("-","gm"),"/")).getTime();
	    		var endTimeLong = new Date(timeEnd.replace(new RegExp("-","gm"),"/")).getTime();
	            
	    		var mindle = (endTimeLong - startTimeLong) * (value / 100) + startTimeLong;
	    		$('#currenttime').val(getSmpFormatDateByLong(mindle,true));
            	Current_time=mindle;
            	
            	if (status.toString() == 'false') {
            		
            		console.log('kai shi bo fang');
            		play2();
            	}
            	
	    		
	            /*
	            $.post("${pageContext.request.contextPath}/interferencequery/findCurrentDate.do",{data:value,startTime:TimeBeginlong,frontId:FrontId}, function(result){
	            	if (result == null || result.rows == null || result.rows.timeStamp == null || result.rows.timeStamp.lenght < 1) return;
	            	var timeStamp = parseInt(result.rows.timeStamp);
	            	$('#currenttime').val(getSmpFormatDateByLong(timeStamp,true));
	            	Current_time=timeStamp;
	            	play2();
	    			console.log(result);
	    		},"json");
	            */
	        }
	    });
		
		$.post("${pageContext.request.contextPath}/frontProcessorInfo/list.do", function(result){
			
			var r = result.rows;
			for (var i = 0; i < r.length; i++) {
				bottomNoiseThreshold[r[i].siteName] = r[i].bottomNoiseThreshold;
			}
			
		},"json");
		
		
        fscandata = $('#fscandata').datagrid({
            //idField : 'id',
            dataPlain: true,
            fit : true,
            striped : true,
            fitColumns : false,
            rownumbers :true,
            border : false,
            nowrap : false,
            columns :  [[ {
                field : 'scanTime',
                title : '扫描时间',
                width : 200,
                align:'center'
            }, {
                field : 'frontProcessorId',
                title : '前置机号',
                width : 140,
                align:'center'
            }, {
                field : 'BSName',
                title : '基站',
                width : 140,
                align:'center'
            }, {
                field : 'recordId',
                title : '文件名编号',
                width : 100,
                align:'center',
                editor:'文件名编号'
            }, {
                field : 'MCC',
                title : 'MCC',
                width : 100,
                align:'center',
            },{
                field : 'MNC',
                title : 'MNC',
                width : 100,
                align:'center',
            }, {
                field : 'LAC',
                title : 'LAC',
                width : 100,
                align:'center',
            },{
                field : 'CID',
                title : 'CID',
                width : 100,
                align:'center',
            },{
                field : 'BCCH',
                title : 'BCCH',
                width : 100,
                align:'center',
            },{
                field : 'BSIC',
                title : 'BSIC',
                width : 100,
                align:'center',
            },{
                field : 'RXLEV',
                title : 'RXLEV',
                width : 100,
                align:'center',
            },{
                field : 'TRXs',
                title : 'TRXs',
                width : 270,
                align:'center',
            }]],
            onContextMenu : function(e, row) {
                 e.preventDefault();
                $(this).treegrid('unselectAll');
                $(this).treegrid('select', row.id);
            },
            onLoadSuccess:function(){
                //加载成功后，checkbox不可以手动勾选
            }
        });

	});
	
	/* 采用每读一分钟就显示1分钟的数据的方法来对频谱进行显示 */
    function getvalues(){
    	tmpFrontId=$("#frontId").combobox("getText");
    	if(tmpFrontId!=""){
    		 $.post("${pageContext.request.contextPath}/interferencequery/fsfrontId.do",{frontId:tmpFrontId},function(result){
    		    TimeBegin=result.startTime;
    		    TimeEnd=result.endTime;
    		    $("#i1").datebox('setValue', TimeBegin);
       		    $("#i2").datebox('setValue', TimeEnd);
    		 },"json");
    		 
    	}
    	else{
    		$.messager.alert("系统提示","请先选择前置机号！");
    	}
    }
    
    function continuegetvalues(frontId,beginTime,endTime){
    	FSpectrum=new Array();
        FSpectrum1=new Array();
        currenttime=new Array();
        FScan=new Array();
        
    	$.post("${pageContext.request.contextPath}/interferencequery/fslist.do",{frontId:frontId,startTime:beginTime,endTime:endTime,isAdjust:isAdjust,isfsreplay:"1"},
        		function(fsresult){
        		var fs=fsresult.rows1;  //上行频谱数据
        		var fs1=fsresult.rows;  //下行频谱数据
        		FScan=fsresult.fscan;
        		for(var i=0;i<fs.length;i++){
        			FSpectrum[i]=new Array();
        			FSpectrum[i]=fs[i].rawMessage.split(",");
        			currenttime[i]=fs[i].timeStamp;
        			FSpectrum1[i]=new Array();
        			FSpectrum1[i]=fs1[i].rawMessage.split(",");
        			poleup[i]=fs[i].pole;
        			poledown[i]=fs1[i].pole;
        			getdata=true;
        		}},"json"); 
    }
    
    function play(){
    	index=0;
    	$("#fscandata").datagrid("loadData", { total: 0, rows: [] });
    	clearInterval(timer);
    	clearInterval(timer2);
    	flag=true;
        status=false;
        isreplay=false;
        status2=false;
        isreplay2=false;
        FSpectrum=new Array();
        FSpectrum1=new Array();
        currenttime=new Array();
        FScan=new Array();
		BusyModelUp=new Array();
        BusyModelDown=new Array();
        LeisureModelUp=new Array();
        LeisureModelDown=new Array();

    	FrontId=$("#frontId").combobox("getText");
    	
    	setupBSInfo(FrontId);

    	TimeBegin=$("#i1").datebox("getValue");
    	TimeEnd=$("#i2").datebox("getValue");
    	var startTimeLong = new Date(TimeBegin.replace(new RegExp("-","gm"),"/")).getTime();
		var endTimeLong = new Date(TimeEnd.replace(new RegExp("-","gm"),"/")).getTime();
		if(startTimeLong-endTimeLong>=0){
			$.messager.alert("系统提示","查询开始时间"+TimeBegin+"不能大于结束时间"+TimeEnd+"！");
			return;
		}
    	time=parseInt($("#speed").combobox("getText"),10);
    	time=time*1000;
    	if(FrontId==""||TimeBegin==""||TimeEnd==""){
    		$.messager.alert("系统提示","请先选择参数！");
    	}
    	else{
    		TimeBeginlong=parseInt(new Date(TimeBegin.replace(new RegExp("-","gm"),"/")).getTime(),10);
    	    MiddleTime=TimeBeginlong+1000*60;
    	    TimeEndlong=parseInt(new Date(TimeEnd.replace(new RegExp("-","gm"),"/")).getTime(),10);
    	    if(MiddleTime>TimeEndlong){
    	    	MiddleTime=TimeEndlong;
    	    }
    	     
    	  	  $.post("${pageContext.request.contextPath}/interferencequery/fslist.do",{frontId:FrontId,startTime:TimeBeginlong,endTime:MiddleTime,isAdjust:isAdjust,isfsreplay:"1"},
            		function(fsresult){
            		var fs=fsresult.rows1;
            		var fs1=fsresult.rows;
            		FScan=fsresult.fscan;
            		console.log(FScan);
            		for(var i=0;i<fs.length;i++){
            			FSpectrum[i]=new Array();
            			FSpectrum[i]=fs[i].rawMessage.split(",");
            			currenttime[i]=fs[i].timeStamp;
            			FSpectrum1[i]=new Array();
            			FSpectrum1[i]=fs1[i].rawMessage.split(",");
            			poleup[i]=fs[i].pole;
            			poledown[i]=fs1[i].pole;
            		}
					getvalueModelDown();
            		/* con();
            		con2(); */
            		},"json"); 
    	} 
	}
	function getvalueModelDown(){
		$.post("${pageContext.request.contextPath}/interferencequery/bsmodellist.do",{frontId:FrontId,direction:"1"},function(result){
			try{
    	  		var r=result.rows;
    	  		for(var i=0;i<463;i++)
    	  		{
    	  			if(i<11||i>451)
    	  			{
    	  				BusyModelDown[i]=null;
    	  				LeisureModelDown[i]=null;
    	  			}
    	  			else{
    	  				BusyModelDown[i]=parseFloat(r[i-11].busyFloor);
    	  				LeisureModelDown[i]=parseFloat(r[i-11].leisureFloor);
    	  			}
    	  		}
    	  		getvalueModelUp();
			}catch(error){
				getvalueModelUp();
			}
    			},"json"); 
	}
    
	function getvalueModelUp(){
		$.post("${pageContext.request.contextPath}/interferencequery/bsmodellist.do",{frontId:FrontId,direction:"0"},function(result){
			try{
    	  		var r=result.rows;
    	  		for(var i=0;i<463;i++)
    	  		{
    	  			if(i<11||i>451)
    	  			{
    	  				BusyModelUp[i]=null;
    	  				LeisureModelUp[i]=null;
    	  			}
    	  			else{
    	  				BusyModelUp[i]=parseFloat(r[i-11].busyFloor);
    	  				LeisureModelUp[i]=parseFloat(r[i-11].leisureFloor);
    	  			}
    	  		}
                chartplay();      
			}catch(error){
				chartplay();    
			}
    			},"json");
		
	}
    /* 改变速度后的执行函数 */
    function play2(){    
    	clearInterval(timer);
    	clearInterval(timer2);
    	flag=true;
        status=false;
        isreplay=false;
        status2=false;
        isreplay2=false;
        FSpectrum=new Array();
        FSpectrum1=new Array();
        currenttime=new Array();
    	var Front_Id=$("#frontId").combobox("getText");
    	var Time_Begin=$("#i1").datebox("getValue");
    	var Time_End=$("#i2").datebox("getValue");
    	var startTimeLong = new Date(Time_Begin.replace(new RegExp("-","gm"),"/")).getTime();
		var endTimeLong = new Date(Time_End.replace(new RegExp("-","gm"),"/")).getTime();
		 if(startTimeLong-endTimeLong>=0){
			 $.messager.alert("系统提示","查询开始时间"+Time_Begin+"不能大于结束时间"+Time_End+"！");
			 return;
		 }
    	if(Front_Id==""||Time_Begin==""||Time_End==""){
    		$.messager.alert("系统提示","请先选择参数！");
    	}
    	else{
    		time=parseInt($("#speed").combobox("getText"),10);
        	time=time*1000; //预留处理时间
    		TimeBeginlong=Current_time;
    	    MiddleTime=TimeBeginlong+1000*60;
    	    if(MiddleTime>TimeEndlong){
    	    	MiddleTime=TimeEndlong;
    	    }
    	    
    		$.post("${pageContext.request.contextPath}/interferencequery/fslist.do",{frontId:FrontId,startTime:TimeBeginlong,endTime:MiddleTime,isAdjust:isAdjust,isfsreplay:"1"},
            		function(fsresult){
            		var fs=fsresult.rows1;
            		var fs1=fsresult.rows;
            		for(var i=0;i<fs.length;i++){
            			FSpectrum[i]=new Array();
            			FSpectrum[i]=fs[i].rawMessage.split(",");
            			currenttime[i]=fs[i].timeStamp;
            			FSpectrum1[i]=new Array();
            			FSpectrum1[i]=fs1[i].rawMessage.split(",");
            			poleup[i]=fs[i].pole;
            			poledown[i]=fs1[i].pole;
            		}
            		/* con();
            		con2(); */
            		if(isAdjust=="0"){
            			chartplay();
            		}
            		else{
            			adjust();
            		}
            	},"json"); 
    	}
	}
    
    
	Highcharts.setOptions({
    	global: {
        	useUTC: false
    	},
		lang: {
			printChart:"打印图表",
         	downloadJPEG: "下载JPEG图片" , 
         	downloadPDF: "下载PDF文档"  ,
         	downloadPNG: "下载PNG图片"  ,
         	downloadSVG: "下载SVG矢量图" , 
         	exportButtonTitle: "导出图片" 
   		}
	});
	
	function formatData(val,row){
		return row.data.Data;
	};

	var frequencySpectrum_CURRENT_QUANTITY;
	
	var toArray = function(s){  
	    try{  
	        return Array.prototype.slice.call(s);  
	    } catch(e){  
	            var arr = [];  
	            for(var i = 0,len = s.length; i < len; i++){  
	                //arr.push(s[i]);  
	                 arr[i] = s[i];     //据说这样比push快
	            }  
	             return arr;  
	    } 
	}
    function dealwith(obj){
    	if( obj == '暂停' ){
    		  status=true;
    		  status2=true;
    		  clearInterval(timer);
    	      clearInterval(timer2);
    	      document.getElementById('operation').value = '播放';
    	}
    	else{
    		  status=false;
    		  status2=false;
    		  play2();
    	      document.getElementById('operation').value = '暂停';
    	}
    }
    
	Highcharts.setOptions({
	    global: {
	        useUTC: false
	    }
	});
		
	Highcharts.setOptions({
	    // 所有语言文字相关配置都设置在 lang 里
	    lang: {
	        resetZoom: '重置',
	        resetZoomTitle: '重置缩放比例'
	    }
	});
    
	    var chart1=new Highcharts.chart({
	    	credits:{
			     enabled:false // 禁用版权信息
			},
	        chart: {
	        	renderTo: 'container',   //通过 chart.renderTo 来指定highchart名称
	                type: 'spline',
	            	zoomType: 'xy',
	    	        animation: Highcharts.svg, // don't animate in old IE
	    	        marginRight: 10,
	    	        events: {
	    	            load: function () {
	    	                // set up the updating of the chart each second
	    	            } 
	    	        }
	        },
	        title: {
	            text: '频谱回放(上行)'
	        },
	        xAxis: {
	        	tickInterval:21, 
	        	allowDecimals:false,
	        	title: {
	                text: '信道号(Channel)'
	            },
	               categories:[]
	        },
	        yAxis: {
	            title: {
	                text: '频谱值(dBm)'
	            },
	            labels: {
	                formatter: function () {
	                    return this.value + '';
	                }
	            },
	            tickInterval: 2,
	            tickPositions: [-120,-110,-100,-90,-80, -70, -60,-50,-40,-30,-20]
	        },
	        tooltip: {
	            crosshairs: true,
	            shared: true,
	            valueDecimals : 1
	        },
	        plotOptions: {
	            spline: {
	                marker: {
	                    radius: 4,
	                    lineWidth: 0.5
	                }
	            }
	        },
	        exporting: {
		        enabled: true
		    },
	        series: [{
	            name: '频谱信号',
	            marker: {
	            	 enabled: false
	            }, 
	            data: [],
	            color:'#0000FF',
	            lineWidth: 0.9,
	            turboThreshold: 10000
	        },{
	            name: '忙时底噪',
	            marker: {
	            	 enabled: false
	            }, 
	            data: [],
	            color:'#000000',
	            lineWidth: 0.9,
	            visible: false
	            
	        },{
	            name: '闲时底噪',
	            marker: {
	            	 enabled: false
	            }, 
	            data: [],
	            color:'#ff0000',
	            lineWidth: 0.9,
	            visible: false
	        }]
	    });
    
	    var chart2=new Highcharts.chart({
	    	credits:{
			     enabled:false // 禁用版权信息
			},
	        chart: {
	        	renderTo: 'container2',
	            type: 'spline',
	            	zoomType: 'xy',
	    	        animation: Highcharts.svg, // don't animate in old IE
	    	        marginRight: 10,
	    	        events: {
	    	            load: function () {
	    	                // set up the updating of the chart each second
	    	                //var series_FSpectrum = this.series[0];
	    	            } 
	    	        }
	        },
	        title: {
	            text: '频谱回放(下行)'
	        },
	        xAxis: {
	        	tickInterval: 21,
	        	allowDecimals:false,
	        	title: {
	                text: '信道号(Channel)'
	            },
	               categories:[]
	        },
	        yAxis: {
	        	pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>',
	            title: {
	                text: '频谱值(dBm)'
	            },
	            labels: {
	                formatter: function () {
	                    return this.value + '';
	                }
	            },
	            tickInterval: 2,
	            tickPositions: [-120,-110,-100,-90,-80, -70, -60,-50,-40,-30,-20]
	        },
	        tooltip: {
	            crosshairs: true,
	            shared: true,
	            valueDecimals : 1
	        },
	        plotOptions: {
	        	turboThreshold:10000,
	            spline: {
	                marker: {
	                    radius: 4,
	                    lineColor:['#7cb5ec', '#434348', '#90ed7d'],
	                    lineWidth: 0.5
	                }
	            }
	        },
	        exporting: {
		        enabled: true
		    },
	        series: [{
	            name: '频谱信号',
	            marker: {
	            	 enabled: false
	            }, 
	            data: [],
	            color:'#0000FF',
	            lineWidth: 1,
	            turboThreshold: 10000
	        },{
	            name: '忙时底噪',
	            marker: {
	            	 enabled: false
	            }, 
	            data: [],
	            color:'#000000',
	            lineWidth: 0.9,
	            visible: false
	            
	        },{
	            name: '闲时底噪',
	            marker: {
	            	 enabled: false
	            }, 
	            data: [],
	            color:'#ff0000',
	            lineWidth: 0.9,
	            visible: false
	        }]
	    });
	    /* 为了同步,因为先前用到了两个setInterval,这样会导致不同步，所以把highchart的显示函数提出来，该函数要放在chart1、chart2定义后的地方，正常情况下的显示函数 */
		function chartplay(){
			var series_FSpectrum = chart1.series[0];  //上行
			var series_BusyUp=chart1.series[1];
			var series_LeisureUp=chart1.series[2];
			var series_FSpectrum2 = chart2.series[0];  //下行
			var series_BusyDown=chart2.series[1];
			var series_LeisureDown=chart2.series[2];
			var p1=0;
			/* x轴 */
            chart1.xAxis[0].update({          
            	title: {
	                text: '信道号(Channel)'
	            }
  	        	});
            chart2.xAxis[0].update({          
            	title: {
	                text: '信道号(Channel)'
	            }
  	        	});
            var tmp=998;
            var sum=0; 
            for(var j=998;j<=1020;j=j+1/21){
            	if(sum==21){
            		chart1.xAxis[0].categories.push(tmp+1);
            		chart2.xAxis[0].categories.push(tmp+1);
            		tmp=tmp+1;
            		sum=0;
            	}
            	else{
            		chart1.xAxis[0].categories.push(j);
            		chart2.xAxis[0].categories.push(j);
            	}
            	sum=sum+1;
            } 
			if(FSpectrum.length!=0){
		        $('#currenttime').val(getSmpFormatDateByLong(parseInt(currenttime[p1], 10),true));
		        document.getElementById("pole_up").value=poleup[p1];
		        document.getElementById("pole_down").value=poledown[p1];
		        Current_time=parseInt(currenttime[p1], 10);
		        var arr=new Array(); //
		        var arr2=new Array();
	  	        for(var i=0;i<463;i++)
	  	        {
	  	            if(i<11||i>451)
	  	            {
	  	            	arr[i]=null;
	  	            	arr2[i]=null;
	  	            				
	  	            }
	  	            else{
	  	            	arr[i]=parseFloat(FSpectrum[p1][i-11]);
	  	            	arr2[i]=parseFloat(FSpectrum1[p1][i-11]);
	  	            	if (bottomNoiseThreshold.hasOwnProperty(FrontId)) {
	  	          			reference = bottomNoiseThreshold[FrontId];
	  	          		}
	  	            	if(arr[i]<reference){
	  	            		arr[i]=reference+(Math.random()*2*range-range);
	  	            	}
	  	            	if(arr2[i]<reference){
	  	            		arr2[i]=reference+(Math.random()*2*range-range);
	  	            	}
	  	            		
	  	            }
	  	         }
	  	            
	  	            series_FSpectrum.setData(arr);
	  	            series_FSpectrum2.setData(arr2);
	  	            series_BusyUp.setData(BusyModelUp);
	  	            series_LeisureUp.setData(LeisureModelUp);
	  	            series_BusyDown.setData(BusyModelDown);
	  	            series_LeisureDown.setData(LeisureModelDown);
	 	            if((!status2))
	 	            		p1++;
	 	            if(isreplay){
	 	            		p1=0;
	 	            		isreplay=false;
	 	            }
	 	            var tmpfscan=0;
	    		 timer=setInterval(fn, time);
	             function fn() {
	         	   if(p1<FSpectrum.length){
	         		  	$('#currenttime').val(getSmpFormatDateByLong(parseInt(currenttime[p1], 10),true));
	         		 	document.getElementById("pole_up").value=poleup[p1];
	 		          	document.getElementById("pole_down").value=poledown[p1];
		         		Current_time=parseInt(currenttime[p1], 10);
		         		
		         		var timeBegin=$("#i1").datebox("getValue");
			        	var timeEnd=$("#i2").datebox("getValue");
			        	var startTimeLong = new Date(timeBegin.replace(new RegExp("-","gm"),"/")).getTime();
			    		var endTimeLong = new Date(timeEnd.replace(new RegExp("-","gm"),"/")).getTime();
		         		var value = parseInt((Current_time - startTimeLong) / (endTimeLong - startTimeLong) * 100);
		         		if (value > 0 && value < 100 ) {
		         			var sliderValue = $('#inp').slider("getValue", value);
		         			if (sliderValue != value) {
		         				$('#inp').slider("setValue", value);
		         			}		         		
		         		}
		         		//console.log('Current_time: ' + Current_time);

		         		for (var j = tmpfscan; j < FScan.length; j++){
       					   
	         			   if (parseInt(FScan[j].scanTime,10) <= Current_time) {
	         				   //break;
	         				   // 获取fscan表格中的全部数据
	         				   var fscanAllData = $('#fscandata').datagrid("getRows");
//	         				   if (fscanAllData.length < 2) break;         
	         				   var hasRepeat = false;
	         				   // 如果是重复数据，则不添加
	         				   for (var k = 0; k < fscanAllData.length; k++) {
	         					   if (fscanAllData[k].LAC == FScan[j].LAC && fscanAllData[k].CID == FScan[j].CID) {
	         						   hasRepeat = true;
	         						   break;
	         					   }
	         				   }
	         				   if (!hasRepeat) {
	         					  $('#fscandata').datagrid('insertRow',{
		         			            index:index ,  // 索引从0开始
		         			            row: {
		         			             scanTime: getSmpFormatDateByLong(parseInt(FScan[j].scanTime,10), true),
		         			             frontProcessorId: FScan[j].frontProcessorId, 
		         			             BSName: FScan[j].BSName,
		         						 recordId: FScan[j].recordId,
		         						 MCC:FScan[j].MCC,
		         						 MNC:FScan[j].MNC,
		         						 LAC:FScan[j].LAC,
		         						 CID:FScan[j].CID,
		         						 BCCH:FScan[j].BCCH,
		         						 BSIC:FScan[j].BSIC,
		         						 RXLEV:FScan[j].RXLEV,
		         						 TRXs:FScan[j].TRXs
		         			            }
		         			      });
	         				   }
	         				   tmpfscan++;
	         				   index++;
	         			   }
	         			   else
	         				   break;
	         		   }
	         		  var arr=new Array();
	         		  var arr2=new Array();
		              for(var i=0;i<463;i++)
		              {
		            	if(i<11||i>451)
		            	{
		            		arr[i]=null;
		            		arr2[i]=null;
		            				
		            	}
		            	else{
		            		arr[i]=parseFloat(FSpectrum[p1][i-11]);
		            		arr2[i]=parseFloat(FSpectrum1[p1][i-11]);
		            		if (bottomNoiseThreshold.hasOwnProperty(FrontId)) {
		                		reference = bottomNoiseThreshold[FrontId];
		                	}
		            		if(arr[i]<reference){
		  	            		arr[i]=reference+(Math.random()*2*range-range);
		  	            		
		  	            	}
		  	            	if(arr2[i]<reference){
		  	            		arr2[i]=reference+(Math.random()*2*range-range);
		  	            	}
		            		}
		            	}
		                series_FSpectrum.setData(arr);
		                series_FSpectrum2.setData(arr2);
		                series_BusyUp.setData(BusyModelUp);
		  	            series_LeisureUp.setData(LeisureModelUp);
		  	            series_BusyDown.setData(BusyModelDown);
		  	            series_LeisureDown.setData(LeisureModelDown);
	            		if((!status2))
	            			p1++;
	             		if(isreplay){
	            			p1=0;
	            			isreplay=false;
	            		}
	             }
	            else{
	         	    TimeBeginlong=MiddleTime;
	         	    MiddleTime=MiddleTime+60000;
	         	    if(MiddleTime>TimeEndlong){
	         	    	MiddleTime=TimeEndlong;
	         	    }
	         	    if(TimeBeginlong<TimeEndlong){
	         	    	FSpectrum=new Array();
	         	        FSpectrum1=new Array();
	         	        currenttime=new Array();
	         	        FScan=new Array();
	         	    	$.post("${pageContext.request.contextPath}/interferencequery/fslist.do",{frontId:FrontId,startTime:TimeBeginlong,endTime:MiddleTime,isAdjust:isAdjust,isfsreplay:"1"},
	         	        		function(fsresult){
	         	        		var fs=fsresult.rows1;
	         	        		var fs1=fsresult.rows;
	         	        		FScan=fsresult.fscan;
	         	        		for(var i=0;i<fs.length;i++){
	         	        			FSpectrum[i]=new Array();
	         	        			FSpectrum[i]=fs[i].rawMessage.split(",");
	         	        			currenttime[i]=fs[i].timeStamp;
	         	        			FSpectrum1[i]=new Array();
	         	        			FSpectrum1[i]=fs1[i].rawMessage.split(",");
	         	        			poleup[i]=fs[i].pole;
	         	        			poledown[i]=fs1[i].pole;
	         	        		}
	         	        		p1=0;
	         	        		tmpfscan=0;
	     	        			status=true;
	     	        			fn();},"json"); 
	 	                
	         	     } 
	         	   
	         		   if(isreplay){
	         			  p1=0; 
	         			  isreplay=false;
	         		   }
	         	   }
	             }
	    	}
		}
	    
		/*调整频率范围后执行的函数  */
		function dealwithadjust(obj){
			if( obj == '频谱扩展' ){
	    		  isAdjust="1";
	    	      document.getElementById('adjust').value = '返回原来频谱范围';
	    	      adjust();
	    	}
	    	else{
	    		  isAdjust="0";
	    	      document.getElementById('adjust').value = '频谱扩展';
	    	      chart1.xAxis[0].update({          
	  	        	tickInterval: 21,
	  	        	title: {
		                text: '信道号(Channel)'
		            }
	  	        	});
	  	        chart2.xAxis[0].update({          
	  	        	tickInterval: 21,
	  	        	title: {
		                text: '信道号(Channel)'
		            }
	  	        	});
	            var tmp=998;
	            var sum=0; 
	            var x1=new Array();
	            var x2=new Array();
	            var cal=0;
	            for(var j=998;j<=1020;j=j+1/21){
	            	if(sum==21){
	            		x1[cal]=tmp+1;
	            		x2[cal]=tmp+1;
	            		chart1.xAxis[0].categories.push(tmp+1);
	            		chart2.xAxis[0].categories.push(tmp+1);
	            		tmp=tmp+1;
	            		cal=cal+1;
	            		sum=0;
	            	}
	            	else{
	            		x1[cal]=j;
	            		x2[cal]=j;
	            		cal=cal+1;
	            	}
	            	sum=sum+1;
	            } 
	            chart1.xAxis[0].setCategories(x1);  //更新x轴显示
	            chart2.xAxis[0].setCategories(x2);
	    	    play2();
	    	}
		}
	    function adjust(){    
	    	clearInterval(timer);
	    	clearInterval(timer2);
	    	flag=true;
	        status=false;
	        isreplay=false;
	        status2=false;
	        isreplay2=false;
	        FSpectrum=new Array();
 	        FSpectrum1=new Array();
 	        currenttime=new Array();
			BusyModelUpAd=new Array();
            BusyModelDownAd=new Array();
            LeisureModelUpAd=new Array();
            LeisureModelDownAd=new Array();
 	        FScan=new Array();
	        chart1.xAxis[0].update({          
	        	tickInterval: 21*2,
	        	title: {
	                text: '频率(MHz)'
	            }
	        	});
	        chart2.xAxis[0].update({          
	        	tickInterval: 21*2,
	        	title: {
	                text: '频率(MHz)'
	            }
	        	});
	    	var Front_Id=$("#frontId").combobox("getText");
	    	var Time_Begin=$("#i1").datebox("getValue");
	    	var Time_End=$("#i2").datebox("getValue");
	    	var startTimeLong = new Date(Time_Begin.replace(new RegExp("-","gm"),"/")).getTime();
			var endTimeLong = new Date(Time_End.replace(new RegExp("-","gm"),"/")).getTime();
			 if(startTimeLong-endTimeLong>=0){
				 $.messager.alert("系统提示","查询开始时间"+Time_Begin+"不能大于结束时间"+Time_End+"！");
				 return;
			 }
	    	if(Front_Id==""||Time_Begin==""||Time_End==""){
	    		$.messager.alert("系统提示","请先选择参数！");
	    	}
	    	else{
	    		time=parseInt($("#speed").combobox("getText"),10);
	        	time=time*1000;
	    		TimeBeginlong=Current_time;
	    	    MiddleTime=TimeBeginlong+1000*60;
	    	    if(MiddleTime>TimeEndlong){
	    	    	MiddleTime=TimeEndlong;
	    	    }
	    		$.post("${pageContext.request.contextPath}/interferencequery/fslist.do",{frontId:FrontId,startTime:TimeBeginlong,endTime:MiddleTime,isAdjust:isAdjust,isfsreplay:"1"},
	            		function(fsresult){
	            		var fs=fsresult.rows1;
	            		var fs1=fsresult.rows;
	            		FScan=fsresult.fscan;
	            		for(var i=0;i<fs.length;i++){
	            			FSpectrum[i]=new Array();
	            			FSpectrum[i]=fs[i].rawMessage.split(",");
	            			currenttime[i]=fs[i].timeStamp;
	            			FSpectrum1[i]=new Array();
	            			FSpectrum1[i]=fs1[i].rawMessage.split(",");
	            			poleup[i]=fs[i].pole;
	            			poledown[i]=fs1[i].pole;
	            		}
	            		chartplayadjust();},"json"); 
	    		
	    	}
			 
		}
	    
		/* 调整后的显示 */
	    function chartplayadjust(){
			var series_FSpectrum = chart1.series[0];  //上行
			var series_FSpectrum2 = chart2.series[0];  //下行
			var series_BusyUp=chart1.series[1];
			var series_LeisureUp=chart1.series[2];
			var series_BusyDown=chart2.series[1];
			var series_LeisureDown=chart2.series[2];
			var p1=0;
			/* x轴 */
			var tmp=879.5;
			var tmp1=929.5;
            var sum=0;
            var cal=0;
            var x1=new Array();
            var x2=new Array();
            for(var j=879.5;j<=904.5;j=j+0.2/21){
            	if(sum==21){
            		tmp=tmp+0.2;
            		tmp1=tmp1+0.2;
            		if(cal==42+525){
            			x1[cal]=(tmp.toFixed(1)+"(999)");
            		}
            		else if(cal==63+525){   //1000
            			x1[cal]=(tmp.toFixed(1)+"(1000)");
            		}
            		else if(cal==84+525){   //1001
            			x1[cal]=(tmp.toFixed(1)+"(1001)");
            		}
            		else if(cal==105+525){
            			x1[cal]=(tmp.toFixed(1)+"(1002)");
            		}
            		else if(cal==399+525){  //1016
            			x1[cal]=(tmp.toFixed(1)+"(1016)");
            		}
            		else if(cal==420+525){  //1017
            			x1[cal]=(tmp.toFixed(1)+"(1017)");
            		}
            		else if(cal==441+525){  //1018
            			x1[cal]=(tmp.toFixed(1)+"(1018)");
            		}
            		else if(cal==462+525){   //1019
            			x1[cal]=(tmp.toFixed(1)+"(1019)");
            		}
            		else{ 
            			x1[cal]=(tmp.toFixed(1));
            		}
            		if(cal==42){
	            		x2[cal]=(tmp1.toFixed(1)+"(999)");
            		}
            		else if(cal==63){   //1000
	            		x2[cal]=(tmp1.toFixed(1)+"(1000)");
            		}
            		else if(cal==84){   //1001
	            		x2[cal]=(tmp1.toFixed(1)+"(1001)");
            		}
            		else if(cal==105){
	            		x2[cal]=(tmp1.toFixed(1)+"(1002)");
            		}
            		else if(cal==399){  //1016
	            		x2[cal]=(tmp1.toFixed(1)+"(1016)");
            		}
            		else if(cal==420){  //1017
	            		x2[cal]=(tmp1.toFixed(1)+"(1017)");
            		}
            		else if(cal==441){  //1018
	            		x2[cal]=(tmp1.toFixed(1)+"(1018)");
            		}
            		else if(cal==462){   //1019
	            		x2[cal]=(tmp1.toFixed(1)+"(1019)");
            		}
            		else{ 
	            		x2[cal]=(tmp1.toFixed(1));
            		}
            		sum=0;
            	}
            	else{
            		x1[cal]=j;
            	    x2[cal]=j+45+5;
            	}
            	sum=sum+1;
            	cal=cal+1;
            } 
            chart1.xAxis[0].setCategories(x1);  //更新x轴显示
            chart2.xAxis[0].setCategories(x2);
			if(FSpectrum.length!=0){
		        $('#currenttime').val(getSmpFormatDateByLong(parseInt(currenttime[p1], 10),true));
		        document.getElementById("pole_up").value=poleup[p1];
		        document.getElementById("pole_down").value=poledown[p1];
		        Current_time=parseInt(currenttime[p1], 10);
		        var arr=new Array(); //
		        var arr2=new Array();
	  	        for(var i=0;i<2520;i++)
	  	        {	  	      
	  	            arr[i]=parseFloat(FSpectrum[p1][i]);
	  	            arr2[i]=parseFloat(FSpectrum1[p1][i]);
	  	             BusyModelUpAd[i]=null;
	    			 BusyModelDownAd[i]=null;
	    			 LeisureModelUpAd[i]=null;
	    			 LeisureModelDownAd=null;
	    			 if (bottomNoiseThreshold.hasOwnProperty(FrontId)) {
	    		    		reference = bottomNoiseThreshold[FrontId];
	    		    	}
	    			 if(arr[i]<reference){
	  	            	arr[i]=reference+(Math.random()*2*range-range);
	  	            }
	  	            if(arr2[i]<reference){
	  	            	arr2[i]=reference+(Math.random()*2*range-range);
	  	            }
	  	        }
	  	        series_FSpectrum.setData(arr);
	  	        series_FSpectrum2.setData(arr2);
	  	        series_BusyUp.setData(BusyModelUpAd);
	            series_LeisureUp.setData(LeisureModelUpAd);
	            series_BusyDown.setData(BusyModelDownAd);
	            series_LeisureDown.setData(LeisureModelDownAd);
	 	        if((!status2))
	 	            	p1++;
	 	        if(isreplay){
	 	            	p1=0;
	 	            	isreplay=false;
	 	         }
	    		 timer=setInterval(fn, time);
	    		 var tmpfscan=0;
	             function fn() {
	         	   if(p1<FSpectrum.length){
	         		  $('#currenttime').val(getSmpFormatDateByLong(parseInt(currenttime[p1], 10),true));
	         		 document.getElementById("pole_up").value=poleup[p1];
	 		         document.getElementById("pole_down").value=poledown[p1];
	         		  Current_time=parseInt(currenttime[p1], 10);
	         		  for (var j=tmpfscan;j<FScan.length;j++){
	         			   if(parseInt(FScan[j].scanTime,10)<=Current_time){
	         				  $('#fscandata').datagrid('insertRow',{
	         			            index:index ,  // 索引从0开始
	         			            row: {
	         			             scanTime: getSmpFormatDateByLong(parseInt(FScan[j].scanTime,10), true),
	         			             frontProcessorId: FScan[j].frontProcessorId, 
	         			             BSName: FScan[j].BSName,
	         						 recordId: FScan[j].recordId,
	         						 MCC:FScan[j].MCC,
	         						 MNC:FScan[j].MNC,
	         						 LAC:FScan[j].LAC,
	         						 CID:FScan[j].CID,
	         						 BCCH:FScan[j].BCCH,
	         						 BSIC:FScan[j].BSIC,
	         						 RXLEV:FScan[j].RXLEV,
	         						 TRXs:FScan[j].TRXs
	         			            }
	         				  
	         			    }); 
	         				 tmpfscan++;
	         				 index++;
	         			   }
	         			   else
	         				   break;
	         		   }
	         		  var arr=new Array();
	         		  var arr2=new Array();
		              for(var i=0;i<2520;i++)
		              {		            	
		            		arr[i]=parseFloat(FSpectrum[p1][i-11]);
		            		arr2[i]=parseFloat(FSpectrum1[p1][i-11]);
		            		if (bottomNoiseThreshold.hasOwnProperty(FrontId)) {
		                		reference = bottomNoiseThreshold[FrontId];
		                	}
		            		if(arr[i]<reference){
		  	            		arr[i]=reference+(Math.random()*2*range-range);
		  	            	}
		  	            	if(arr2[i]<reference){
		  	            		arr2[i]=reference+(Math.random()*2*range-range);
		  	            	}
		              }
		               series_FSpectrum.setData(arr);
		               series_FSpectrum2.setData(arr2);
	            		if((!status2))
	            			p1++;
	             		if(isreplay){
	            			p1=0;
	            			isreplay=false;
	            		}
	             }
	            else{
	         	    TimeBeginlong=MiddleTime;
	         	    MiddleTime=MiddleTime+60000;
	         	    if(MiddleTime>TimeEndlong){
	         	    	MiddleTime=TimeEndlong;
	         	    }
	         	    if(TimeBeginlong<TimeEndlong){
	         	    	FSpectrum=new Array();
	         	        FSpectrum1=new Array();
	         	        currenttime=new Array();
	         	        FScan =new Array();
	         	    	$.post("${pageContext.request.contextPath}/interferencequery/fslist.do",{frontId:FrontId,startTime:TimeBeginlong,endTime:MiddleTime,isAdjust:"1",isfsreplay:"1"},
	         	        		function(fsresult){
	         	        		var fs=fsresult.rows1;
	         	        		var fs1=fsresult.rows;
	         	        		for(var i=0;i<fs.length;i++){
	         	        			FSpectrum[i]=new Array();
	         	        			FSpectrum[i]=fs[i].rawMessage.split(",");
	         	        			currenttime[i]=fs[i].timeStamp;
	         	        			FSpectrum1[i]=new Array();
	         	        			FSpectrum1[i]=fs1[i].rawMessage.split(",");
	         	        			poleup[i]=fs[i].pole;
	         	        			poledown[i]=fs1[i].pole;
	         	        		}
	         	        		p1=0;
	         	        		tmpfscan=0;
	     	        			status=true;
	     	        			fn();},"json"); 
	 	                
	         	     } 
	         	   
	         		   if(isreplay){
	         			  p1=0; 
	         			  isreplay=false;
	         		   }
	         	   }
	             }
	    	}
		}
	   
	    
	/*时间转换函数  */
	Date.prototype.format = function (format) {  
        var o = {  
            "M+": this.getMonth() + 1,  
            "d+": this.getDate(),  
            "h+": this.getHours(),  
            "m+": this.getMinutes(),  
            "s+": this.getSeconds(),  
            "q+": Math.floor((this.getMonth() + 3) / 3),  
            "S": this.getMilliseconds()  
        }  
        if (/(y+)/.test(format)) {  
            format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));  
        }  
        for (var k in o) {  
            if (new RegExp("(" + k + ")").test(format)) {  
                format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));  
            }  
        }  
        return format;  
    }  
    /**   
    *转换日期对象为日期字符串   
    * @param date 日期对象   
    * @param isFull 是否为完整的日期数据,   
    *               为true时, 格式如"2000-03-05 01:05:04"   
    *               为false时, 格式如 "2000-03-05"   
    * @return 符合要求的日期字符串   
    */    
    function getSmpFormatDate(date, isFull) {  
        var pattern = "";  
        if (isFull == true || isFull == undefined) {  
            pattern = "yyyy-MM-dd hh:mm:ss S";
        } else {  
            pattern = "yyyy-MM-dd";  
        }  
        return getFormatDate(date, pattern);  
    }  
    
    function getSmpFormatDateByLong(date, isFull) {  
        return getSmpFormatDate(new Date(date), isFull);  
    }  
    
    function getFormatDate(date, pattern) {  
        if (date == undefined) {  
            date = new Date();  
        }  
        if (pattern == undefined) {  
            pattern = "yyyy-MM-dd hh:mm:ss S";
        }  
        return date.format(pattern);  
    }  
    
    formatterDate = function (date) {
    	var day = date.getDate();
    	var month = (date.getMonth() + 1);
    	var hor = date.getHours();
    	var min = date.getMinutes();
    	var sec = date.getSeconds();
        var Millisecond = date.getMilliseconds();
        // Millisecond = Millisecond < 100 ? ('00' + Millisecond) : (Millisecond < 10 ? ('0'+Millisecond) : Millisecond);
    	return date.getFullYear() + '-' + month + '-' + day+" "+hor+":"+min+":"+sec;
    };

    $(function(){
    	$('#i1').datetimebox('setValue', formatterDate(new Date(new Date(new Date().toLocaleDateString()).getTime())));
    	$('#i2').datetimebox('setValue', formatterDate(new Date()));
    	/*
    	$.post("${pageContext.request.contextPath}/frontProcessorInfo/find.do", function(result){
			console.log(result);
    	},"json");
    	*/
    });
    
    function setupBSInfo(frontId) {
    	$.post("${pageContext.request.contextPath}/frontProcessorInfo/find.do", function(result){
    		var info = '';
    		for(var i = 0; i < result.length; i++){
    			var bs_info = result[i];

    			if (bs_info.BSName == frontId) {
    				info = '本小区 ' + frontId + ':' + bs_info.BCCH + '/' + bs_info.TCH1 + '/';
    				if (bs_info.TCH2) info += (bs_info.TCH2 + '/');
    				if (bs_info.TCH3) info += (bs_info.TCH3);
    				info += '\n';
    				var fres = bs_info.fres.split(';');
    				for (var j = 0; j < fres.length; j++) {
    					info += '邻小区 ' + fres[j] + '\n';
    				}

    				 console.log(info);
    		    	$('#bs_info').html(info);
					break;
    			}
    		}
    	},"json");
    }

</script>
</body>
</html>